home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Can anyone HELP with variable delaration? Please?
- Date: Sat, 06 Apr 96 21:36:15 GMT
- Organization: none
- Message-ID: <828826575snz@genesis.demon.co.uk>
- References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca> <3162de71.18703379@news.ucs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <3162de71.18703379@news.ucs.ubc.ca>
- jamesdf@unixg.ubc.ca "James Fairweather" writes:
-
- >>Any variable can be declared constant, including strings:
- >>
- >> const char * const str = "Foo";
- >>
- >>Or do you mean literal constants?
- >>
- >I'm not sure what the difference is. I thought the keyword "const"
- >was just for the compiler. If you tried to modify the variable
- >declared const, the compiler would complain. Does it do something
- >else with the variable if you declare it const?
-
- It doesn't have to but it can legally put it (i.e. the pointer) in
- non-writable memory since the program can't legally write to it. The compiler
- can always put a string literal in non-writable memory since the program can
- never legally write to one.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-